---@class Battle.BuffBase
---@field New fun():Battle.BuffBase
local BuffBase = Battle.CreateClass("BuffBase")
Battle.BuffBase = BuffBase
function BuffBase:OnCreate()
    self.buffId = 0
    self.overlay = 1    --叠加层级
    self.targetId = 0   --挂载对象
    self.isInDuring = false
    self.curTime = 0
    self.during = 0     --持续时间
    self.maxOverlay = 1--最大叠加数量
    self.sourceBuffId = nil
    self.sourceSkillId = nil
end
function BuffBase:Set(buffId,overlay,targetId,during,sourceSender,sourceSkillId,sourceBuffId)
    ---@type Battle.Entity
    self.sourceSender = sourceSender
    self.buffId = buffId
    self.overlay = overlay
    self.targetId = targetId
    self.during = during
    self.curTime = 0
    self.sourceSkillId = sourceSkillId
    self.sourceBuffId = sourceBuffId
end
function BuffBase:SetDuring(during)
    self.during = during
end
---当buff销毁后(已从buff容器中移除)
function BuffBase:OnDestroy()

end
function BuffBase:ToString()
    local str = string.format("[id:%d,叠加层数:%d,目标英雄:%d,持续时间:%0.1f",self.buffId,self.overlay,self.targetId,self.during)
    if self.sourceSender then
        str = str ..",来源英雄:"..self.sourceSender.id
    end
    if self.sourceSkillId then
        str = str..",来源技能:"..self.sourceSkillId
    end
    if self.sourceBuffId then
        str = str..",来源buff:"..self.sourceBuffId
    end
    str = str.."]"
    return str

end

function BuffBase:Update(dt)
    if self.isInDuring  and self.during >= 0 then
        self.curTime = self.curTime + dt
        if self.curTime > self.during then
            self.isInDuring = false
            self:OnBuffRemove()
        end
    end

end
---实例化后，生效前调用(还未加入buff容器中)
function BuffBase:OnBuffAwake()

end
---buff生效时
function BuffBase:OnBuffStart(...)

end
---相同类型时刷新(更新buff层数、等级、持续时间等)
function BuffBase:OnBuffRefresh(overlay)

end
---当buff销毁前(还未从buff容器中移除)
function BuffBase:OnBuffRemove()

end

---定时器间隔触发开始
function BuffBase:StartIntervalThink()

end
---定时器间隔触发
function BuffBase:OnIntervalThink()

end
